// import { Suspense } from "react";
// import { BrowserRouter, Routes, Route } from "react-router-dom";
import routes from "./router/index";
import { useRoutes } from "react-router-dom";
import { Suspense, useState } from "react";
import ChartAI from "./views/chart-ai/index";

function App() {
  console.log("routes", routes);
  const ElementRouter = useRoutes(routes);
  const [isVisible, setIsVisible] = useState(false);
  // 切换显示和隐藏的函数
  const toggleVisibility = () => {
    setIsVisible(!isVisible);
  };
  return (
    <>
      {isVisible && <ChartAI />}

      <div className="fixed bottom-3 right-6" onClick={toggleVisibility}>
        {/* AI 触发 */}
        <img
          src="https://img0.baidu.com/it/u=1919234148,3077342933&fm=253&fmt=auto&app=138&f=PNG?w=256&h=256"
          alt=""
          className="w-10 h-10 "
        />
      </div>

      {/* Suspense包裹异步组件 */}
      <Suspense fallback={<div>Loading...</div>}>
        {/* <Router></Router> */}
        {ElementRouter}
      </Suspense>
    </>
  );
}
export default App;
